package cn.edu.xmu.orderpayment.payment.model.bo;

import cn.edu.xmu.orderpayment.payment.model.vo.SimpleAdminUser;
import lombok.*;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Guanlin Wang 22920192204282
 * @date 2021/12/15
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class Refund {
    /**
     * 单状态
     */
    public enum State{
        PENDING_PAYMENT((byte)0 ,"待退款"),
        PAYMENT_COMPLETED((byte)1,"已退款"),
        RECONCILIATION_COMPLETED((byte)2, "已对账"),
        LIQUIDATION_COMPLETED((byte)3, "已清算"),
        PAYMENT_FAILED((byte)4, "退款失败"),
        CANCELED((byte)5, "取消");

        private static final Map<Integer, State> STATE_MAP;
        static {
            STATE_MAP = new HashMap();
            for (State enum1 : values()) {
                STATE_MAP.put(enum1.code.intValue(), enum1);
            }
        }
        private Byte code;
        private String description;
        State(Byte code, String description) {
            this.code = code;
            this.description = description;
        }

        public Byte getCode() {
            return this.code;
        }

        public String getDescription() {
            return this.description;

        }
        public static State getStateByCode(Integer code) {
            return STATE_MAP.get(code);
        }
    }

    public State getState() {
        return State.getStateByCode(Integer.valueOf(state));
    }
    public void setState(State state) {
        this.state=state.getCode().byteValue();
    }

    public DocumentType getDocumentType() {
        return DocumentType.getDocumentTypeByCode(Integer.valueOf(documentType));
    }
    public void setDocumentType(DocumentType documentType) {
        this.documentType=documentType.getCode().byteValue();
    }

    public enum DocumentType{
        NORMAL(0,"订单"),
        BOND(1,"保证金"),
        AFTERSALE(2,"售后");
        private static final Map<Integer, DocumentType> DOCUMENT_TYPE_MAP;
        static {
            DOCUMENT_TYPE_MAP = new HashMap();
            for (DocumentType enum1 : values()) {
                DOCUMENT_TYPE_MAP.put(enum1.code, enum1);
            }
        }
        private int code;
        private String description;
        DocumentType(int code, String description) {
            this.code = code;
            this.description = description;
        }
        public static DocumentType getDocumentTypeByCode(Integer code) {
            return DOCUMENT_TYPE_MAP.get(code);
        }
        public Integer getCode() {
            return code;
        }
        public String getDescription() {
            return description;
        }
    }

    private Long id;
    private String tradeSn;
    private Long patternId;
    private Long paymentId;
    private Long amount;
    private String documentId;
    private Byte documentType;
    private LocalDateTime refundTime;
    private Byte state;
    private String descr;
    private Long adjustId;
    private String adjustName;
    private LocalDateTime adjustTime;
    private Long creatorId;
    private String creatorName;
    private Long modifierId;
    private String modifierName;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTradeSn() {
        return tradeSn;
    }

    public void setTradeSn(String tradeSn) {
        this.tradeSn = tradeSn;
    }

    public Long getPatternId() {
        return patternId;
    }

    public void setPatternId(Long patternId) {
        this.patternId = patternId;
    }

    public Long getPaymentId() {
        return paymentId;
    }

    public void setPaymentId(Long paymentId) {
        this.paymentId = paymentId;
    }

    public Long getAmount() {
        return amount;
    }

    public void setAmount(Long amount) {
        this.amount = amount;
    }

    public String getDocumentId() {
        return documentId;
    }

    public void setDocumentId(String documentId) {
        this.documentId = documentId;
    }

    public void setDocumentType(Byte documentType) {
        this.documentType = documentType;
    }

    public LocalDateTime getRefundTime() {
        return refundTime;
    }

    public void setRefundTime(LocalDateTime refundTime) {
        this.refundTime = refundTime;
    }


    public void setState(Byte state) {
        this.state = state;
    }

    public String getDescr() {
        return descr;
    }

    public void setDescr(String descr) {
        this.descr = descr;
    }

    public Long getAdjustId() {
        return adjustId;
    }

    public void setAdjustId(Long adjustId) {
        this.adjustId = adjustId;
    }

    public String getAdjustName() {
        return adjustName;
    }

    public void setAdjustName(String adjustName) {
        this.adjustName = adjustName;
    }

    public LocalDateTime getAdjustTime() {
        return adjustTime;
    }

    public void setAdjustTime(LocalDateTime adjustTime) {
        this.adjustTime = adjustTime;
    }

    public Long getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(Long creatorId) {
        this.creatorId = creatorId;
    }

    public String getCreatorName() {
        return creatorName;
    }

    public void setCreatorName(String creatorName) {
        this.creatorName = creatorName;
    }

    public Long getModifierId() {
        return modifierId;
    }

    public void setModifierId(Long modifierId) {
        this.modifierId = modifierId;
    }

    public String getModifierName() {
        return modifierName;
    }

    public void setModifierName(String modifierName) {
        this.modifierName = modifierName;
    }

    public LocalDateTime getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(LocalDateTime gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public LocalDateTime getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(LocalDateTime gmtModified) {
        this.gmtModified = gmtModified;
    }
}
